From 640f891eb258563bb155e577389e8c5e6541a59a Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 21 May 2015 08:57:19 +0200 Subject: [PATCH] vmap: avoid hitting an ASSERT with vfree(NULL) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit and unconditionally defer the vm_size() call, as it doesn't have a NULL short circuit. Reported-by: Wei Liu Signed-off-by: Andrew Cooper Tested-by: Wei Liu Reviewed-by: Roger Pau Monné Acked-by: Tim Deegan --- xen/common/vmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index 8752595cdb..ac66a8c41b 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -268,10 +268,14 @@ void *vzalloc(size_t size) void vfree(void *va) { - unsigned int i, pages = vm_size(va); + unsigned int i, pages; struct page_info *pg; PAGE_LIST_HEAD(pg_list); + if ( !va ) + return; + + pages = vm_size(va); ASSERT(pages); for ( i = 0; i < pages; i++ ) -- 2.30.2